package com.youngking.guns.core.util;

public class verify {
    /**
     * 验证密码复杂度
     *
     * @return
     */
    public String verifycomplex(String pwd, int settingLength, String settingComplex) {
        String tipLength = "";
        String tipStr = "";
        if (settingLength > 0) {
            if (pwd.length() < settingLength) {
                tipLength = "密码长度必须大于" + (settingLength - 1) + "位.";
            }
        }
        if (settingComplex.indexOf("sum") != -1) {
            if (Common.HasDigit(pwd) == false) {
                tipStr += "数字,";
            }
        }
        if (settingComplex.indexOf("small") != -1) {
            if (Common.judgeContainsStr(pwd) == false) {
                tipStr += "小写字母,";
            }
        }
        if (settingComplex.indexOf("big") != -1) {
            if (Common.judgeContainsStr1(pwd) == false) {
                tipStr += "大写字母,";
            }
        }
        if (settingComplex.indexOf("sym") != -1) {
            if (Common.isSpecialChar(pwd) == false) {
                tipStr += "特殊字符,";
            }
        }

        if (tipLength != "" || tipStr != "") {
            return tipLength + "密码必须包含" + tipStr.substring(0, tipStr.length() - 1);
        } else {
            return "ok";
        }
    }
}